let rec my_scan n s = 
  let ns = read_line () in
  let t = String.length ns in 
  let f = try String.sub ns (t-2) 2 with _ -> "" in
    if n = 0 then begin
	if f = ";;" then s^(String.sub ns 0 (t-2))
        else my_scan (n+1) (s^ns)
    end
    else 
      begin 
	if f = ";;" then s^"\n"^(String.sub ns 0 (t-2))
         else my_scan (n+1) (s^"\n"^ns)
      end

let _ =
  Eval.initialise ();
  while(true) do
    let expr = my_scan 0 "" in 
      try 
	print_string (Eval.eval expr)
      with Failure a ->
	print_string a;
	print_newline();
  done
